package test;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

public class JiSuan {
	String gongshi;
	String x;
	String y;
	double b;

	void JiSuan1(String gongshi, String x, String y) {
		this.gongshi = gongshi;
		this.x = x;
		this.y = y;
		gongshi = gongshi.replace("x", x);
		gongshi = gongshi.replace("y", y);
		System.out.println(gongshi);

		ScriptEngineManager manager = new ScriptEngineManager();

		ScriptEngine engine = manager.getEngineByName("javascript");
		try {
			b = (Double) engine.eval(gongshi);
		} catch (ScriptException ex) {

		}
	}

	public static void main(String[] args) {
		new JiSuan().JiSuan1("x*y-(2*x-10*y)/x", "6", "76");

	}

}
